package com.demo.controler;

import com.demo.dao.SeckillDao;
import com.demo.dao.SuccessKilledDao;
import com.demo.pojo.Seckill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

/**
 * @ClassName: Control
 * @Description: 控制器
 * @Author: zzz
 * @Date: 2020-03-29 21:40
 */
@Controller
@RequestMapping("")
public class Control {
    //@Autowired
    //SeckillDao sd ;
    @Autowired //@Resource
    private SeckillDao seckillDao;

    @Autowired //@Resource
    private SuccessKilledDao successKilledDao;

    @RequestMapping("demo")
    @ResponseBody
    String demo() {
        Date now = new Date();
        System.out.println(seckillDao.queryById(10001));
        Seckill s= new Seckill();
        s.setName("zh藏南");
        System.out.println(seckillDao.addItem(s));
        System.out.println("hf11212fhz走走走");
        return "time";
    }

    @RequestMapping(value = "list",method = RequestMethod.GET)
    public String list(Model model)
    {
        //list.jsp+mode=ModelAndView
        //获取列表页
        List<Seckill> list=seckillDao.queryAll(0,10);
        model.addAttribute("list",list);
        System.out.println(list);
        return "list";
    }
}
